<template>
	<view>

		<div id="my_note">
			<div class="nav">
				<ul class="am-avg-sm-4">
					<li class="cur" @click="waitorder">待付款</li>
					<li @click="pay">已付款</li>
					<li @click="waituse">待使用</li>
					<li @click="waitcomment">待评价</li>
				</ul>
			</div>
			<div id="app">
				<div class="cont">
					<ul v-for="b in order">
						<li>
							<div class="box_cont">
								<div title="" @click="itemClicked(b)">
									<div class="pic">
										{{b.active_name}}<br><!-- {{b.time}} -->
										<span class="date">{{b.address_name}}</span>
										<span class="date">{{b.address_address}}</span>
									</div>
									<div class="project_cont">
										<p>{{b.active_cost}}</p><!-- <right></right> -->
									</div>

								</div>
							</div>
							{{b.time}}
							<div class="button" style="display: inline-block;    display: inline-flex;">
								<button   @click="deleteorder(b)" value="删除" >
								删除
							</button>
							<button  class="gray_hollow" @click="pay1(b)" value="支付">支付
				</button>
			</div>
			</li>
			</ul>
			<div id="none">
				没有更多了
			</div>
		</div>
		</div>
		</div>
	</view>
</template>

<script>
	import config from '@/config'
	export default {
		data() {
			return {
				uni,
				usr: '',
				order: {},
				type: 0,
			}
		},
		methods: {
			waitorder: function() {
				uni.redirectTo({ //跳转我的页面
					url: 'waitorder',
				});
			},
			pay: function() {
				uni.redirectTo({ //跳转我的页面
					url: 'pay',
				});
			},
			waituse: function() {
				uni.redirectTo({ //跳转我的页面
					url: 'waituse',
				});
			},
			waitcomment: function() {
				uni.redirectTo({ //跳转我的页面
					url: 'waitcomment',
				});
			},
			itemClicked: function(item) {
				//console.log("进入获取id")
				this.id = item.id;
				uni.navigateTo({
					url:'../../../pages/active/activity_detail?id'+this.id
				})
			},
			deleteorder: function(item) {

				this.id = item.id;
				console.log("id=" + this.id);
				
				url: `${config.baseUrl}/comment/deleteorder?token=` + uni.getStorageSync('token'), {
						'id': this.id,
					}

					.then(function(r) {
						if (r.data.succ) {
							alert(r.data.msg);
						} else {
							alert(r.data.msg);
						}
					})
					.catch(function(error) {
						// 网络错误
					});
				console.log("aaaaaaaaaa");
			},


			pay1: function(item) {

				this.id = item.id;
				console.log("id=" + this.id);

				url: `${config.baseUrl}/comment/payorder?token=` + uni.getStorageSync('token'), {
						'id': this.id,
					}
					.then(function(r) {

						if (r.data.succ) {
							alert(r.data.msg);
						} else {
							alert(r.data.msg);
						}
					})
					.catch(function(error) {
						// 网络错误
					});
			},
		},
		onLoad() {
			var that = this;
			uni.request({
				url: `${config.baseUrl}/comment/waitorder?token=` + uni.getStorageSync('token'),
				method: 'GET',
				success(r) {
					if (r.data.succ) {
						that.order = r.data.data;
					}
				}
			});
		}
	}
</script>

<style type="text/css">
	.input {
		width: 50px;
		height: 40px;

	}
</style>
